<template>
  <el-menu default-active="1-4-1" class="el-menu-vertical-demo" background-color="#122121" text-color="#fff" :collapse="isCollapse">
    <h3>{{isCollapse?'系统':'校园单车共享系统'}}</h3>
    <el-menu-item @click="clickMenu(item)" v-for="item in noChildren" :index="item.path" :key="item.path">
      <i :class="'el-icon-' + item.icon"></i>
      <span slot="title">{{item.label}}</span>
    </el-menu-item>
    <el-submenu v-for="item in hasChildren" :index="item.pash" :key="item.path">
      <template slot="title">
        <i :class="'el-icon-' + item.icon"></i>
        <span slot="title">{{item.label}}</span>
      </template>
      <el-menu-item-group v-for="(subItem, subIndex) in item.children" :key="subItem.path">
        <el-menu-item :index="subIndex">
          <i :class="'el-icon-' + subItem.icon"></i>
          <span slot="title">{{subItem.label}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>

<script>
export default {
  name: "CampusBikeSharingCommonaside",
  data() {
    return {
      menu: [
        {
          path: "/",
          name: "home",
          label: "首页",
          icon: "s-home",
          url: "Home/Home",
        },
        {
          path: "/bike",
          name: "bike",
          label: "车辆信息管理",
          icon: "s-marketing",
          url: "Bike/Bike",
        },
        {
          path: "/student",
          name: "student",
          label: "学生信息管理",
          icon: "s-custom",
          url: "Student/Student",
        },
        {
          path: "/admin",
          name: "admin",
          label: "系统用户管理",
          icon: "s-grid",
          url: "Admin/Admin",
        },
        {
          path: "/rent",
          name:"rent",
          label: "租赁信息管理",
          icon: "s-unfold",
          url:"Rent/Rent"
        },
      ],
    };
  },
  mounted() {},
  methods: {
    clickMenu(item){
      this.$router.push({
        name:item.name
      })
    }
  },
  computed: {
    noChildren() {
      return this.menu.filter((item) => !item.children);
    },
    hasChildren() {
      return this.menu.filter((item) => item.children);
    },
    isCollapse(){
      return this.$store.state.tab.isCollapse;
    }
  },
};
</script>

<style lang="less" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu {
  height: 100%;
  border: none;
  h3 {
    color: #fff;
    text-align: center;
    line-height: 60px;
    margin: 0;
  }
}
</style>
